package cn.itsource.ymcc.openfeign.factory;

import cn.itsource.ymcc.result.JsonResult;
import feign.hystrix.FallbackFactory;
import cn.itsource.ymcc.openfeign.UserOpenfeign;
import org.springframework.stereotype.Component;


@Component
public class UserOpenfeignFallbackFactory implements FallbackFactory<UserOpenfeign> {
    @Override
    public UserOpenfeign create(Throwable throwable) {
        return new UserOpenfeign() {
            @Override
            public JsonResult get(Long id) {
                throwable.printStackTrace();//写了这个可以在控制台里面看
                return JsonResult.error(throwable.getMessage());
            }
        };
    }
}
